﻿
using System;
using System.Threading;
using System.Threading.Tasks;

namespace WSU.ChekaParallel.TestTask
{
    static class TestResultTask
    {
        private static void TestGetResult()
        {
            // you can call StartNew or StartNew<string>, both cases are legal
            // because generic type can be infered by compiler
            Task<string> resultTask = Task.Factory.StartNew(state =>
                {
                    Thread.Sleep(1000);
                    return (string)state;
                }, "cheka");

            Console.WriteLine("task has been started, ......");
            // if task is still running, call "Result" property will block caller thread to wait for the result
            Console.WriteLine("task completed with result<{0}>", resultTask.Result);
        }

        public static void TestMain(string[] args)
        {
            TestGetResult();
        }
    }
}